<?php 

namespace Home\Model;

use Think\Model;

class DepartmentModel extends Model{

    protected $_validate = array(
	
		array('department', 'require', '部门名称不能为空！'),
		
    );

	public function update($_post){
		
		$data = $this->create($_post);
		
		if(empty($data)){
			
			return false;
			
		}
		
		if(empty($data['id'])){
			
			$id = $this->add();
			
			if(!$id){
				
				$this->error = '新建出错！';
				
				return false;
				
			}
			
		}else{
			
			$status = $this->save();
			
			if(false === $status){
				
				$this->error = '更新出错！';
				
				return false;
				
			}
			
		}
		
		return $data;
		
	}

}